#pragma once
#ifndef GFXENTITYTERRAIN_H
#define GFXENTITYTERRAIN_H


#include "GfxEntity.h"
#include "Visualisation.h"
class CGfxEntityTerrain:public CGfxEntity
{
private:

	//fvf definition
	struct vertexTerrain
	{
		D3DXVECTOR3 m_position;
		D3DXVECTOR3 m_normal;
		float m_textureUCoordinate;
		float m_textureVCoordinate;
	};
	#define VERTEXTERRAIN_FVF (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)

	D3DXVECTOR3 m_minBounds;
	D3DXVECTOR3 m_maxBounds;
	int m_numCellsWide;
	int m_numCellsHigh;
	int m_numVertices;
	int m_numTriangles;
	LPDIRECT3DVERTEXBUFFER9 m_vertexBuffer;
	LPDIRECT3DINDEXBUFFER9 m_indexBuffer;
	LPDIRECT3DTEXTURE9 m_texture;
	vector<D3DXVECTOR3> m_vertexArray;
	//calculated variables
	int m_numVertsX;
	int m_numVertsZ;

	D3DMATERIAL9 m_material;

public:
	CGfxEntityTerrain(int numCellsWide, int numCellsHigh, D3DXVECTOR3 minBound, D3DXVECTOR3 maxBound);
	~CGfxEntityTerrain(void);
	void createTerrain(void);
	void doRender();

	//gettors
	D3DXVECTOR3 getMinBound()const;
	D3DXVECTOR3 getMaxBound()const;
	int getNumCellWidth()const;
	int getNumCellHigh()const;
	D3DXVECTOR3 getVertex(int indexVertex)const;
};

#endif